import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
 * 
 * @author Tamer Saadeh
 * @version 0.1 (beta)
 */
public class ConverterCMD {
	public static void main(String[] args) throws NumberFormatException, IOException {
		Converter c = new Converter();
		int x = 1;
		while(x != 0){
			System.out.println("Converter: \nSyntax: (type anything random on the first line) \nnumber\nfrom currency\nto currency\nEnter:");
			BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
			String line = "";
			Double amount = new Double(0.0);
			String to = "";
			String from = "";
			int loop = 0;
			while ((line = in.readLine()) != null && loop <=2) {
				if(loop == 0){
					amount = new Double(line);
				}else if(loop == 1){
					from = line;
				}else if(loop == 2){
					to = line;
				}
				++loop;
			}
			Double result = c.convert(amount, from, to);
			System.out.println("Result:\n" + amount + " " + from + " is " + result + " " + to);
			System.out.println("continue (1) or exit (0) ?");
			BufferedReader ino = new BufferedReader(new InputStreamReader(System.in));
			line = "";
			line = ino.readLine();
			Integer y = new Integer(line);
			x = y.intValue();
			if(x==0){
				System.out.println("Bye and thanks for using the program!!");
			}
			in.close();
			ino.close();
		}
	}
}
